Problem 31: a bit more clean up