CHG: two nested ifs to one