added error when new main category exists and bug fix when not exists