Modified maxDistance