moved the chat logic insto a separate module