Why not having the switch inside the loop?