remove one level of nested loops/ifs