Random search algorithm 1