solves problem 16