find rays in random algorithm working