adopt new algorithm to findAllpaths()