write cacheSolve function