Fixed detection of unclosed brackets