critical distance calculation fix