completed problem 2 of exercise 6