more correct and better caching - now it works with method references too