BUG: handle overwriting existing keys.

Fix handling of overwriting a value for an existing key