fix the switching glitch