refactoring client code to support multiple room in the same window