check conditions in class instead of template file