Cleaned up IsPermutation