Almost done fixing query builder