solution to Problem 4