Added chapter 6 code