Refactoring some code into base class.