More work on chapter 5 - optimization