final fixes for chapter 3 code