updated tree code