query builder improvements