Use switch instead of lots of ifs