fix typo and add check

for some reason the query is returning duplicate key/value pairs where
one is just an integer with a value and the other is the actual name of
the field and the value.