Factors common code out of media functions