Added code for chapter 7