change function to prevent blinking