Implemented cache function