Calculate totals before using them