Getpaths function