changed the logic to calcualte the sum at every process operation instead of waiting till endwindow