Refactor media search