added function to matrix2