Improvements on the random algorithm