Refactored the code and added rooms