added latest code including changes in tree