Completed the string permutation check