Better matching of functions in regard of ref