add runtime check to matsub