closures in a loop, localize variables