refactor code for virtual hosting