organizing code and separating cache.js