caching virtual method algorithm is working