rewrite getrandom script