code optimization for video popup