new version with xml and no global variable