those two ifs can be combined