rewrite the random.js