fixed a bug when there is no userAgent header the code crashes