Refactoring folded evaluation of scoped for loop environment