Refactor accumulate.