Fix problem with nested brackets

The closest definition is now activated, not just the first in order.