Fixing distance check.