modified chat.js