Revert "simplifying loops"

This reverts commit e1162493c4a7e7ce701db7e80e3ee47841fcf638.