refactored chat code to use the user object instead of the username as a string