Fixed duplicate message issue by checking for last message id vs message timestamp