refactored to improve accumulators