Implement cacheSolve