added tree functionality