Corrected potential bug in search logic
Corrected compilation error