Adding more code for chapter 5