get rid of nested ifs