Optimized rand.rb file