Code presented in chapter 9