Fix Search Algorithm bug