use the nextpermutation