refactoring tree router