solves problem 1