Simplify path-extraction algorithm