Code for Chapter 9