refactoring of findImages/findVideos