Refactor if statement to early return

This eliminates the protracted if statement and aligns the code body.