rewrote rand.sh, much better now