refactoring chatroom plugin