diff --git a/ConvertData.m b/ConvertData.m
new file mode 100644
index 0000000000000000000000000000000000000000..a4281c9e3c9b857c34bdf24246d31aa6c60338a8
--- /dev/null
+++ b/ConvertData.m
@@ -0,0 +1,25 @@
+function[convertedData]=ConvertData(orgData, varNames, rowNames)
+%function[convertedData]=ConvertData(orgData, varNames, rowNames)
+% if varnames is not supplied, uses the first column of the table as varNames, and then deletes the column. 
+% if rowNames is not supplied, the variable names of the input table is used. 
+% Note that all names are converted to valid variable/row names. In order
+% to transpose, the table is converted to a cell array and back. This might
+% introduce error, so make sure that the results are as expected!
+
+
+if nargin<2
+    varNames=orgData{:,1};
+    orgData(:,1)=[];
+end
+if nargin<3
+    rowNames=orgData.Properties.VariableNames;
+end
+varNames=matlab.lang.makeValidName(varNames);
+rowNames=matlab.lang.makeValidName(rowNames);
+
+t=table2cell(orgData);
+convertedData=cell2table(t');
+convertedData.Properties.VariableNames=varNames;
+convertedData.Properties.RowNames=matlab.lang.makeValidName(rowNames);
+
+end
\ No newline at end of file
diff --git a/nonunique.m b/nonunique.m
index cda8d85885cc94a9b66cb3e12e2be95a6fb858b4..04e8e920b88d209a751f8085eefce3e1a29ba79c 100644
--- a/nonunique.m
+++ b/nonunique.m
@@ -1,6 +1,6 @@
 function [dupes, ind] = nonunique(A)
 [~, i, ~] = unique(A,'first');
-dupes = A(not(ismember(1:numel(A),i)));
+dupes = unique(A(not(ismember(1:numel(A),i))));
 ind=ismember(A,dupes);
 end