Solves problem 8