factor out cache
factor out cache