added code for tree diagram and a thumbnail