add snapshot and save function