Refactoring QueryBuilder class