mad rewrite of video timing logic