bug fix insert and update