cleaning up solution to prob 1