Fix for solution to problem 31