refactor domain dectection for multisites