modify function writeModelToFile and loadModelFromFile