finished code example for section4, chapter9