Updating count function in flat totals