Fixed error with random generation