Problem 58 Refactor