algo 10x faster for pathfinding