refactoring
chat basics almost done