fix hostname normalization logic