add caching to  to avoid extraneous calls to the accumulator function