foreach usage fix