Improve check locale logic