Chapter 8 sample code