Organized code and added flag variable to avoid calling the infinite scroll 'loadMore..' method when doing a search.