fix a bug when hostname is not defined