Refactor for working with virtual hosts