Adding Chapter 6 code