Instead of nested if statements you could do this as an early return.