refactored pages controller
Merge branch 'general_refactor'