loop fix

Fixed foreach loop