Refactor Problem 30