Solves Problem 2