Improve complete_common_string()