Fixed an infinite for loop.