New code for Chapter 7