Simplifies code at expense of pushing keyField type test into loop