rewrote path conversion algorithm