Fixed the issue with the maximum distance