add nil check, otherwise, Net::HTTP.connect gets error