struggling with totals calculations