pathfinding optimize