refactoring of qtree