Refactored common code