prototype random algorithm