Smarter element id search