Fixed a bug related to the position of a closing bracket which reduces the number of sub-queries