Chatting logic implemented using firebase