Refactored PagesController