added stack usage for balanced brackets