Any difference between the book value loss (or gain) and the cost of modification is recognized as a gain or loss.
A gain or a loss is calculated by the difference between book value loss and cost of modification.