Implemented Problem 3