Better algorithm to use is transform rather than accumulate.