replacing switches with ifs