Chapter 3 code