Adding source code for chapter 4