refactored search controller