Solves problem 7