smarter autolink function