reorganization of pages management code