Add conditional for writetoxml stuff