Move initialiser into for cycle

Closure compiler shows warning on this.

WARNING - Suspicious code. This code lacks side-effects. Is there a bug?