updated search algorithm again