Chapter 4 code