holy nested switches and loops, batman