Fix the flickering problem

Thanks to @ito725.