cleaning up the solution to problem 10