Came up with another solution for Problem 3.