adding code for chapter 5