Implement latest bits of code from chapter 5