Adding code for chapter 12