save switch state