remove trailing unmatched parentheses on model template