trying to fix the issue where the messages appear out of order, and duplicate messages appear sometimes...