Refactoring the video search into a function