chat.js modified to debug the application