BAC-929: fixed main query