Fix foreach loops