changed variable name in prefix tree
fixing bugs for edge cases