fixed javascript error in shorteset distance