Fixing a "closure in a loop" JavaScript problem.

BUG=
R=shailentuli@google.com

Review URL: https://codereview.appspot.com/65500044