Fix the bug in for loop.