checking that user-agent exists before evaluating string