improving solution to prob1, again