added global variable for accumulator
added a function to update said global variable