completed exercise with a foreach loop