refactored to allow for media type mapping