revised cache implementation