improve tree generation