Refactored common code into a base class