Handle duplicate key errors