Revert "pull conditionals out of loop"

Unexpected errors.

This reverts commit a350b61a9f6003eac0306b0bf8254f3951b43def.