Refactor Chat Code To Be More DRY