Fixed incorrect foreach usage