fix bugs in generating SubPath