Move check outside of loop.