Convert from the old if(MATCHES) hack to if(DEFINED) to check whether the result variable is already set.