fix query build