added matrix.to.df function