Refine user agent detector