minor change to matrix_shape (tested)