Adding multiple_submatrices subroutine