Final version of problem 3