corrected indentation and now handles non existing previous key (not
just changed existing)

Signed-off-by: Brian Coca <briancoca+dev@gmail.com>