Fixed a bug where the last bracket was not excluded properly.