Code for chapter 1