final version of problem 1