Problem 54

Refactored