Refactored page code