JSHint: don't define a function within a loop.