improving custom pathfinding for better performance and efficiency