Updated parameter name from pathIndex to stopPathIndex for consistency.