My Solution for Problem 2.