version 2 of problem 1