implemented blockwise evaluation of the sum in counting