fixing save function