refactored medium factory