Extract chat functionality to separate class