removed code repeating at add and update db  methods