fixed generateRan()