working on chapter 5 code