Added word permutation function