updated tree implementation