hacked in fix for max_distance
max_distance hack fix