simplify nested ifs with identical elses