make nested if statements more logical