Years Ended September 30,
Years Ended September 30,
Years Ended September 30,
2019
2018
2017
Net sales
$  —
$  262,228
$  378,152
Costs and expenses:
Cost of sales
—
235,279
342,819
Selling, general and administrative expenses
—
11,365
17,487
Amortization of purchased intangibles
—
1,373
2,752
Restructuring costs
—
7
208
Other income
—
(15)
(46)
Earnings from discontinued operations before income taxes
—
14,219
14,932
Net loss on sale
1,423
6,131
—
Income tax provision
—
3,845
401
Net income (loss) from discontinued operations
$  (1,423)
$  4,243
$  14,531
note 3 — acquisitions and divestitures .
sale of cgd services .
on april 18 2018 we entered into a stock purchase agreement with nova global supply & services llc -purchaser an entity affiliated with gc valiant lp under which we agreed to sell our cgd services business to the purchaser .
we concluded that the sale of the cgd services business met all of the required conditions for discontinued operations presentation in the second quarter of fiscal 2018 .
consequently in the second quarter of fiscal 2018 we recognized a $ 6 .
9 million loss within discontinued operations which was calculated as the excess of the carrying value of the net assets of cgd services less the estimated sales price in the stock purchase agreement less estimated selling costs .
the sale closed on may 31 2018 .
in accordance with the terms of the stock purchase agreement the purchaser agreed to pay us $ 135 .
0 million in cash upon the closing of the transaction adjusted for the estimated working capital of cgd services at the date of the sale compared to a working capital target .
in the third quarter of fiscal 2018 we received $ 133 .
8 million in connection with the sale and we recorded a receivable from the purchaser for the estimated amount due related to the working capital settlement .
the balance of this receivable was $ 3 .
7 million at september 30 2018 .
during fiscal 2019 we worked with the purchaser and revised certain estimates related to the working capital settlement .
in connection with the revision of these estimates we reduced the receivable from the purchaser by $ 1 .
4 million and recognized a corresponding loss on the sale of cgd services in fiscal 2019 .
certain remaining working capital settlement estimates primarily related to the fair value of accounts receivable have not yet been settled with the purchaser .
in addition to the amounts described above we are eligible to receive an additional cash payment of $ 3 .
0 million based on the achievement of pre-determined earn-out conditions related to the award of certain government contracts .
no amount has been recorded as a receivable related to the potential achievement of earn-out conditions based upon our assessment of the probability of achievement of the required conditions .
the operations and cash flows of cgd services are reflected in our consolidated statements of operations and consolidated statements of cash flows as discontinued operations through may 31 2018 the date of the sale .
the following table presents the composition of net income from discontinued operations net of taxes -in thousands : .

Question: How was the loss within discontinued operations in 2018 calculated?
Answer: the excess of the carrying value of the net assets of CGD Services less the estimated sales price in the stock purchase agreement less estimated selling costs