Implemented Problem 4