Improve chat and refactored in modules chat.js and db.js