optimized random() fn.