improve random method