Fixed bug with loop iterated variable in closure