Refactoring out into a class