Add random algorithm, add a flag to set the algorithm