implement count with query and update version