This check can remain outside of the loop