Fix random value generator bug