I want to simplify a condition inside a determinant using coprime factorisations and I need to know if an operation is mathematically correct. This is a simplification of what I'm actually doing, but I only need to know if the last step is okay. I hope it is clear enough such that someone can give me feedback.

Let $A = M^{-1}N$ and $B = XY^{-1}$, these are all nonzero $n\times n$ matrices. Let $D$ also be another $n \times n$ matrix and let $\phi$ be a scalar. These are the steps that I am taking, where I am using that det$(AB) = $ det$(A)$det$(B)$ for $n \times n$ matrices: \begin{align} \text{det}\big(I - D(I + AB)^{-1} \big)\phi & \neq 0 \\ \text{multiply lhs and rhs by det$(I + AB)$} \\ \text{det}\big(I + AB - D)\phi & \neq 0 \\ \text{substitute $A = M^{-1}N$ and $B = XY^{-1}$ } \\ \text{det}\big(I + M^{-1}NXY^{-1} - D)\phi & \neq 0 \\ \text{multiply lhs and rhs by det$(M)$ from left side and det$(Y)$ from right side} \\ \text{det}(M)\cdot \text{det}\big(I + M^{-1}NXY^{-1} - D) \cdot \text{det}(Y) \neq \text{det}(M)\cdot 0 &\cdot \text{det}(Y) \\ \text{det}\big(MY + NX - MDY \big)\phi & \neq 0 \\ \text{Move $\phi$ inside determinant} \\ \text{det}\big(MY\phi^{1/n} + NX\phi^{1/n} - MDY\phi^{1/n} \big) & \neq 0 \end{align}

Is step three mathematically correct?