updated problem 5 solution