better hostname detection