wrote custom tree implementation