code for chapter 3