Bug fix to prevent division by zero due to scaling function when distance is extremely large