added tree alg