Refactor Problem 3