refactoring in _mkdist