added xjg saving function