refactor loadPageContent function