complete function of adding category and editing category