Refactor Problem 23