how two way switching works