Share common code for converting selector to function