chat.js with 2 functions