implemented cache functions for assignment 2