At a closer look, I don't think this is right.
You should add at least 1 to theSeed value: small deltaR can easily make theSeed=0, which will give irreproducible results