remove all redundant ifs