Use switch instead of ifs

For consistency with the rest of the toLevel function. Also fixed a typo.