Code for Chapter 18