handling nested brackets