compute msd with periodic boundary

Hello guys,
I have a small question about compute_msd command. If I use periodic boundary, which atom is used for compute_msd when at the next step the specific atom is out of box and becomes the image atom? Is the image position or the position before periodic adjustment involved in msd calculation? I believe it must be the latter. So can I ask that how does comput_msd command deal with this problem? I cannot find any description in the manual.
Thanks.