implemented counter query builder