fixed foreach loops