finished the exercise for chapter 6