Cleaned up Problem 31