shift the ugly ifs around