refactor use keyToPath to generate path for the key