confused

so one of the guys from my work (diff department) started to messaged me a few months ago, we talk off and on and at times he can be quite flirty, on the rare occasion that i see him at work he acts as if he isnt looking at me but i always catch him looking out the side of his eye at me as he walks past but is always happy to see me when he says hi, idk what to think because sometimes he responds to my messages sometimes he doesnt