Refactor Problem 16