updated query builder and unit test