Refactors Problem 2