Removed xml string concatenation and serialisation and replaced with ElementTree