some chat refactoring