relocated some repetitive code from inside setRoom function, to its own function