refactor tree. working on split function