refactored the EditDistance trait