fixing write xml bug