Fix logic glitch