I am not sure why this is not working, after all if I am correct it should be fine.
But when I run the following
if(lastchatid < obj.id)
it seems not to run.
basiclly lastchatid stores the last chat id and the obj.id is the new obj.id since the last chat id.
I am wondering why this would not work.
If
lastchatidandobj.idare number values you can try using:and then