Refactored search