Fixed distToFrontier bug second time