fixed save function.