count braces
fix brace counting
fix conditional