add code to chapter 9