fix bug with search logic