collapse the ifs