assignment 7 - fix bug in problem 4