added example code for chapter 7.2