How to short the word or avoid repeat word e.g the word is "secretsecret'" the program returns only 'secret' as the word.