Change for loop to for each