refactored control totals
final refactoring