capture immutable value before iterator