updating the foreach loop from a previous version of the loop