update logic for detecting country code