fix scope of nested iterators