Solution to problem 17
Clean up code