Use switch instead of multiple ifs