private int GetRandomNumberUnitValue(INumber number, IEnumerable<int> usedValues, Random random) { var reservedValues = this.unitsToInclude.Select(u => u.Value); var randomNumberUnitValue = random.Next(0, 10); if (number.HasUnitValue(randomNumberUnitValue) || usedValues.Any(v => v == randomNumberUnitValue) || reservedValues.Any(v => v == randomNumberUnitValue) || this.valuesToExclude.Any(v => v == randomNumberUnitValue)) { return this.GetRandomNumberUnitValue(number, usedValues, random); } return randomNumberUnitValue; }