Question: Okay, so I have a `<tr>` table being built from a string that looks something like this: `13467`

```
1= monday
2= tuesday
...
7= sunday
so 13467 = mon,wed,thurs,sat,sun

```

My existing code manually checked the string, like so

```
if (breakfastDays.Contains("1")) {
        sb.Append("<td class=\"active\">&nbsp;</td>");
        mo++;
    } else {
        sb.Append("<td>&nbsp;</td>");
    }

    if (breakfastDays.Contains("2")) {
        sb.Append("<td class=\"active\">&nbsp;</td>");
        tu++;
    } else {
        sb.Append("<td>&nbsp;</td>");
    }

```

The `class="active"`part just tells the `css` to check the box.

Is there an easier way of doing the string checking by any chance?

Perhaps some `for-in` loops maybe?

Answer: 
I would first see if you can get rid of individual variables for the day counters, that seems clunky and issue-prone. That, and reducing this to a simple loop, something like:

```
// Set up buckets for each day, with an initial count of 0
var dayMap = "1234567".ToDictionary(c => c, c => 0);

// For each key ("day")...
foreach (var day in dayMap.Keys.ToList())
{
    // Start writing the cell
    sb.Append("<td");
    // Check if input string contains that key
    if (breakfastDays.Contains(day)) 
    {
        // Increment the value in our day bucket
        dayMap[day]++;
        // Make the cell "active"
        sb.Append(" class=\"active\"");
    } 
    // Finish writing the cell
    sb.Append(">&nbsp;</td>");
}

```
This will fix the issue of having to write seven tests for the table:

```
for (int i = 1; i <= 7; i++)
{
    if (breakfastDays.Contains(i.ToString())
    {
        sb.Append("<td class=\"active\">&nbsp;</td>"));
    }
    else
    {
        sb.Append("<td>&nbsp;</td>");
    }
}

```

We could sure get more clever but I don't want to skip over the importance of `mo++` and `tu++` in your code.