Fix query builder