refactored common code to parent class