Add source code for chapter 3