hack to solve maxDist problem