converted multiple ifs to switch