Completed solution to problem 54