added precalculation of randomization point, improved formatting