Fix bug with filling for loops in loops