Fixing bug in HW 8, Chapter 14 exercise