update solution of problem 9.5