refactored search