Code as of the end of chapter 5