update chapter 8 code