Terminate early and reduce nesting per code review