Solving for problem 3