Welford's formula modified