combined Graham's and Sheivan's parts of PathGenerator