updated search logic