page controller refactor and better error handling when adding / editing a page