Solving for problem 6