fixed tree functions and added times function