refactor chat page