Fix random logic.