implement accumulate