duplicate checking bug fix in insert function