reduce if nesting