Small improvement to save function