Counter Stops without meeting the condition!

Hey Guys, I have been working on this method to assign certain percentage of each letters for the total count of the input Points which defines how many times each of those letters will appear. Then a random pick function selects one letter per iteration and places it on the input Points.
I have a condition to stop the iteration only when the total no. of each letters populated on the points are equal to the percentage count.

private void RunScript(DataTree<Point3d> pts, List<string> inputText, List<double> percent, bool run, ref object A, ref object B)
  {

    int totalCount = pts.DataCount;  //Total Point Count in pts

    //Calculate the percentage of each text type for totalCount
    int actualdCount = RoundPercentageToInt(totalCount, percent[0], 3); //represents d input
    int actualcCount = RoundPercentageToInt(totalCount, percent[1], 2); //represents c input
    int actualbCount = RoundPercentageToInt(totalCount, percent[2], 3); //represents b input
    int actualaCount = totalCount - (actualbCount + actualcCount + actualdCount); //represents a input

    Print("required Count of D: " + actualdCount.ToString());
    Print("required Count of C: " + actualcCount.ToString());
    Print("required Count of B: " + actualbCount.ToString());
    Print("required Count of A: " + actualaCount.ToString());

    Print("//--------//");

    List<string> dList = new List<string>();
    List<string> cList = new List<string>();
    List<string> bList = new List<string>();
    List<string> aList = new List<string>();


    DataTree<string> allText = new DataTree<string>();
    DataTree<Point3d> homePositions = new DataTree<Point3d>();

    //Counter with the run boolean
    if(run)
    {
      counter++;
      this.Component.ExpireSolution(true);
    }

    //Main Part of the SolveInstance
    for(int k = 0; k < pts.BranchCount; k++)
    {
      var branch = pts.Branches[k];
      var path = pts.Paths[k];

      int i = 0;
      while(i < branch.Count)
      {

        int j = 0;
        string randomID = PickRandom(inputText, m);
        if(randomID == "D" & i <= branch.Count - 3 & dList.Count < actualdCount)
        {
          j += 3;

          if(i + j <= branch.Count)
          {
            for(int d = 0; d < j; d++)
            {
              dList.Add(randomID);
              allText.Add(randomID, path);
              homePositions.Add(branch[i + d], path);
            }
          }
        }

        else if(randomID == "B" & i <= branch.Count - 3 & bList.Count < actualbCount)
        {
          j += 3;

          if(i + j <= branch.Count)
          {
            for(int b = 0; b < j; b++)
            {
              bList.Add(randomID);
              allText.Add(randomID, path);
              homePositions.Add(branch[i + b], path);
            }
          }
        }

        else if(randomID == "C" & i <= branch.Count - 2 & cList.Count < actualcCount)
        {
          j += 2;

          if(i + j <= branch.Count)
          {
            for(int c = 0; c < j; c++)
            {
              cList.Add(randomID);
              allText.Add(randomID, path);
              homePositions.Add(branch[i + c], path);
            }
          }
        }

        else
        {
          j += 1;
          if (aList.Count < actualaCount)
          {
            aList.Add("A");
            allText.Add("A", path);
            homePositions.Add(branch[i], path);
          }

        }
        i += j;
        m += counter;
      }

    }

    //Display DashBoard
    Print("Achieved Count of D: " + dList.Count.ToString());
    Print("Achieved Count of C: " + cList.Count.ToString());
    Print("Achieved Count of B: " + bList.Count.ToString());
    Print("Achieved Count of A: " + aList.Count.ToString());
    Print("//--------//");


    //Condition to Stop run boolean
    if(dList.Count == actualdCount & bList.Count == actualbCount & cList.Count == actualcCount & aList.Count == actualaCount)
    {
      var toggle = this.Component.Params.Input[3].Sources[0];
      ((GH_BooleanToggle) toggle).Value = false;
      toggle.ExpireSolution(true);
    }



    A = allText;
    B = homePositions;



  }

  // <Custom additional code> 
  int m;
  int counter;

  public string PickRandom(List<string> myStrings, int seed)
  {
    Random random = new Random(seed);
    int randomIndex = random.Next(myStrings.Count);

    return myStrings[randomIndex];
  }

  public int RoundPercentageToInt(int dividend, double percent, int divisor)
  {
    int roundtoInt;

    int dCount = (int) (dividend * percent / 100);

    if (dCount % divisor == 0)
    {
      roundtoInt = dCount;

    }
    else
    {
      if(dCount % divisor > 1)
      {
        roundtoInt = dCount + 1;
      }
      else
      {
        roundtoInt = dCount - dCount % divisor;
      }
    }
    return roundtoInt;
  }


now the problem I am having is that the solution does run everything properly but it stops without achieving the correct counts, as you can see here.

Any Idea What could I be missing here.

201127_Random PickAndPlace.gh (11.7 KB)

I found and fixed the error. I needed to move the int m to main code and initialize it.
here is the code for those who would be interested.201128_Random PickAndPlace_SU.gh (15.0 KB)