max_distance functionality corrections