solution to Problem 7