bugfix for S matrices with dimensions smaller than 4x4