fixed bug in distToFrontier