correct solution to prob 2