Question Regarding Leveraged Positions

An investor buys a stock on margin and holds the position for one year.

Shares purchased - 700
Purchase price - $22/share
Call money rate - 4%
Dividend - $0.60/share
Leverage ratio - 1.6
Total return on the investment - 12%

Assuming that the interest on the loan and the dividend are both paid at the end of the year, the price at which the investor sold the stock is closest to:

Answer given:
Gain from price appreciation = Total return − Dividend + Margin interest |$1,155 − $420 + $231= $966

|Price at which investor sold the stock = Gain from price appreciation per share + Purchase price |($966/700) + $22 =$23.38

Can someone please explain why we are subtracting the dividend and adding the margin interest in the gain from price appreciation? Doesn’t make any sense to me. Thank you! ( this is taken from a CFA level 1 book practice question.

Solve the equation for total return and it will make sense.