Modified queryBuilder: fix bug with nested conditions