refactored chat.js and added password feature