mergeMatrices returning matrix