Utility function element set bug fix

Thanks to @nmussy