fixing flickering issue