adding chapter 3 code