First version of query builder