fixed error in search logic.