Refactor Problem 17