Code for Chapter 1