added random to search algorithm