added support for large number of matrices if the user manually provides number of rows and columns