Fixed bug in distToFrontier