refractored edit and new forms, moved the common code to form