now with peter's caching logic!