fixing tree writer bug