Replace switch with loop.