I'd use an early-return here to reduce nesting.