refactor keyEncoding and valueEncoding