added braces matching algo