added self-balancing to tree