Sale of Rental Property

I had sales price of $40,000.00
Original Cost was $22,617 with $5,400 of this allocated to land
Prior depreciation on structure was $17,034
Cost of Improvements was $17,306
Prior depreciation on Improvements was $11,835
Sales expense was $,2400

 

When viewing the Form 4797 it shows it shows the recapture of depreciation on the structure and improvements,  but what doesn't appear anywhere is the cost of the improvements/assets purchased. It is stating a gain on the sale of $32,400 as it is not adding the cost of the improvements to the cost basis of the structure. It is showing a loss on the land of $555. So it is recapturing the depreciation taken on the structure and improvements without adding the cost of the improvements to the original purchase price of structure? What do I do?