Refactored the way the local domain is determined