Changed detectName to detect the longest name.