Fix bug in edit_distance