fixed bug where keys & values arrays could be out of sync

Change-Id: I6b4eebc2e091499d2ce273562420832a94efcbd9