Refactor page state control