solves problem 9