Fixed lint failure caused by func definition with a loop.
#1708 code review changes.