updated to reflect code in Listing 2.1