Optimize code foor room leaving