implemented cacheSolve