fix a bug of save function