added codes to tree1 and 2