Refactor Pages Controller