work on fixing refactoring
work on fixing tree functions