refactoring for initial page load from server