fixed total function