modularized the path transform code