media: refactor