# Is $\mathbb{Q}$-factoriality preserved under contraction?

Let ($$X$$,$$\Delta$$) be projective klt pair and $$f \colon X \rightarrow Z$$ be contraction of ($$K_X + \Delta$$) - negative extremal ray $$R$$. If $$X$$ is $$\mathbb{Q}$$ -factorial and $$\mathrm{dim}Z < \mathrm{dim} X$$, then Z is $$\mathbb{Q}$$- factorial?

I have read proof of above claim in Kollar and Mori "Birational geometry of algebraic varieties" but I have some trouble.The proof is following:

Let $$D$$ be effective weil divisor on $$Z$$ and $$Z_0 \subset Z$$ be smooth locus of $$Z$$. $$D'$$ be closure of $$f^{-1}(D \cap Z_0 )$$. By $$\mathbb{Q}$$-factoriality of X, $$mD'$$ is cartier for some $$m \in \mathbb{Z}$$. Since $$D'$$ does not meet general fibre of $$f$$ we have $$D'.R = 0$$ Hence $$mD'$$ is pullback of some cartier divisor on $$Z$$ and $$D$$ is $$\mathbb{Q}$$ cartier.

My trouble is the last statement.

Why $$D$$ is $$\mathbb{Q}$$ cartier since $$mD'$$ is pullback of some cartier divisor on Z?

Let $$D''$$ be a Cartier divisor on $$Z$$ such that $$f^*\mathscr O_Z(D'')\simeq \mathscr O_X(mD')$$. Then by the projection formula $$\mathscr O_Z(D'')\simeq f_*\mathscr O_X(mD')$$ (since $$f_*\mathscr O_X\simeq \mathscr O_Z$$).
On the other hand, from the construction we see that $$\mathscr O_Z(D'')|_{Z_0}\simeq f_*\mathscr O_X(mD')|_{Z_0}\simeq \mathscr O_Z(mD)|_{Z_0}$$. Finally, because $$Z$$ is normal, the complement of $$Z_0$$ has at least codimension $$2$$ in $$Z$$. Both $$\mathscr O_Z(D'')$$ and $$\mathscr O_Z(mD)$$ are reflexive sheaves of rank $$1$$, and they are isomorphic on the complement of a codimension $$2$$ closed set, so they are isomorphic everywhere. Hence $$mD\sim D''$$ which is Cartier.