refactoring new and edit pages