Implemented Problem 2