adding chapter 8 code