Chapter 2 code excerpts