Clean up solution to problem 2