Adding chapter 5 code