Refactoring of QueryBuilder