Searvch function debugged