The function works for most of the city inputs, but there's a part of the domain where the rule does not hold. It couldn't return the country for cities such as Amsterdam and New York. The function seems to work for a subset of the cities only.