Refactor pages display mechanism