Search mechanism refactored