So the main reason why that is there is because PuppetDB returns things like:

```
[
{"key1": "valueA1", 
"key2": "valueA2", 
"key3": "valueA3"},
 {"key1": "valueB1", 
"key2": "valueB2", 
"key3": "valueB3"},
...
]
```

So I wanted to be able to get the column labels without having the table look like (and thus the bad count var)...

```
|key1, key 2, key 3, key 1, key 2, key 3....|
```

However, the way Ajax iterates over the returned json, it first sees every individual {k:v,k2:v2,k3:v3} map is a field and that's what the first each iterates over, and then the second each iterates over each key and value within those fields. So the first chance I can get to get the column label for the table is within that second each statement.

Another way I could do it is to have a function call before the second each to get all the keys from the first field, but then I would still need to make sure that only happened once. I'm not entirely sure how I would get the header attributes then if it were outside of the each in that case. So that was my basic reasoning behind why I did that.