My attempt at chapter 9