Measurable function is Baire class 2 almost everywhere

Let $X$ be a polish space (separable completely metrizable topological space). Let $m$ be a probability measure on $X$ and $f:X \rightarrow \mathbb{R}$ a measureable function. I want to show that $f$ is equal a.e. to a second Baire class function (limits of limits of bounded continuous functions).

I know how to prove this when $f$ is bounded: in that case $f$ is in $L_1(X)$ and there exists a sequence of continuous functions which converge to $f$ a.e. and are uniformly bounded. Then by taking some limits I can deal with the points in which the sequence doesn't converge.

My question is, how to prove for any function $f$, not necessarily bounded?

Thanks, Shlomi

-

It seems to me that the general case follows from the bounded case. If $f$ is not necessarily bounded, consider $\arctan\circ f$ and represent it as a limit of limits of continuous functions. Then apply $\tan$ to all those functions and get the required representation of $f$. (Since all the limits you care about are pointwise limits a.e., the fact that $\tan$ is only continuous, not uniformly so, does no harm.)
I would orefer a reference which treats the locally compact case. That is, if $X$ is locally compact and $\mu$ is a regular bounded Borel mesaure on $X$ and $f$ is some $\mu$-measureable function, then f = g a.e.($\mu$) for some $g$ of second Baire class on $X$. – Fred Dashiell Oct 19 '12 at 21:55