use switch instead of ifs