final versions for chapter 8 exercises