Small refactoring of QueryBuilder