Refactoring of Query Builder