Moving old chapter 8 code