added tree function