Externally checking for local domains.
Adding domain as an argument
Complying to @lloydwatkin 's suggestions