Fixing client side bug in Chat.js