Chapter 3 sample code