several tweaks but main change was making initial distance r=1.05 instead of 1 because of rounding problems