fixed bugs, added validation for add and edit pages and other stuff