Give an example of nonmeasurable function $f:(\mathbb{R}, Leb)\rightarrow \mathbb{R}$ such that $|f|$ is measurable and for every $a\in \mathbb{R}$ , $f^{-1}(\{a\})$ is a measurable set
My idea: suppose $E$ is a nonmeasurable subset of $[0,1]$ and $f:\mathbb{R}\rightarrow \mathbb{R}$ is such that $f(x)=x$ for $x\in E$ and $f(x)=x-e^x$ for $x\in E^{c}$.