Code for chapter 10