Move waiting room logic into waiting function