improve search logic