move cache from variable to sub/method