Add common function for re-factoring
Fix for cache handling