Code for Chapter 12