improved country detection