use foldl instead of foldr in longest_string2