Added the code for chapter 12