Refactoring chat box