Improving the random algorithm