added multiple tree writing