Completed solution for e1.31