rewrite parseUserAgent function