used double buffer to prevent blink glitch