change ifs to cases