add save function (incomplete)