syntax and small bug fix in chat.js