made tree reloadable and refactored