Better checking of variables in template