Refactoring and bug fix for Load more query