improvement on ifs