solves problem 22