Code for Chapter 7