Bug fix with looping.