swapped for for each
switched out for loops for .each method in problem 3