adding sample code for chapter 7