switch to for loop; closure exhibits confusing behavior