Finished chapter 40 example