fixed the query builder