Split out some code to clarify a loop.