add code samples for chapter 7