solves problem 5