FIXED. It was an error in the calculating distance part. We forgot to use the square root/distance formula.