Maybe I'm missing something, but wouldn't this loop be simpler if it were 

```
  while (it != vals.end()) {
    cmd += it->first + " " + valType(it->second);
    ++it;
    cmd += ", ";
  }
```