Made sortedWord just a string to decrease memory utilisation