fix duplicate to handle single column and composite primary keys