fixed xml writing