Finished code in cache.c