finished  chapter 8 exercise