Simplify chapter 1 code