Simplify problem 8 solution