Update foreach loops instead of for