updated problem 8 solution