# conditional independence of functions of random variables

I have a question regarding conditional independence of functions of random variables. Consider three random variables $X, Y, Z$. Suppose $X\perp Y\mid Z$. Is $f(X)\perp f(Y)\mid f(Z)$? I think it holds for monotone continuous function $f(\cdot)$ (which can be shown by factorization after transformation) but in general it doesn't hold.

Let $Z=\pm1$ with some probability and let $f(x) =x^2.$ Then since $f(Z) = 1,$ this function completely erases any information in $Z.$ Then let $X$ and $Y$ be conditionally independent Bernoulli (i.e. zero or one) with a probability $p$ that depends on $Z.$ Then $f(X) = X$ and $f(Y) = Y.$ So $f(X)$ and $f(Y)$ are not conditionally independent on $f(Z)$ (since this is equivalent to $X$ and $Y$ being unconditionally independent).