Chapter 7 sample code