problem 6 refactoring