Working cache function