restructure code for cache datastruct def