Added rest of chapter 2 code