Redid Prob 3 to make slightly more efficient