added handling of duplicate key on insert