smarter key appending, only appends if the key is missing