Updated query builder - new functionality