fixed a bug in trie.add
breaking code into files