fix flickering bug