reduced the if nesting from 4 to 2