Replace random functions with random class.