worked on new chat.js structure