Fixed non-object issue in TemplateCondition