Revert "Remove unnecessary loop"

This reverts commit d81ee36e5fe968ab3960b84be5202a9101f5328d.

The loop wasn't actually unnecessary.