trie write functions re-design - work in progress