improve random mechanism