Refactored search controller