refactory to avoid creating new buffers in string2KV