added hostname_scheme and re-ordered script