add generateAllCaseDistance function