Only switch state if it is different from the new one