reduced amount of nested ifs