adds $scope.total function