Improved perms function and quickcheck function for 8.1