Refactor Problem 27