refactor the syncVideos function