optimize the function and add user-agent .