fix brace counting