optimize path length retrieval
fix type