moved the optional element query into its own nonmember, nonfriend templated function for easier, one-line usage.