Improved video recording function