minor simplification of getPaths function