adding in solution to problem 3