Change the random sampling imlementation to avoid collisions.