failed running counter implementation

tried to implement a running total but failed