added chapter 12 code from mwd book