directly check hostname instead of length to account for NoneType