Make jslint happy by creating functions outside the loop