Refactor PagesController::show function