adding template variable checking