Added second foreach loop to answer question 2 in another way