longestWord functional