Use early returns to reduce nesting.