completed cacheSolve function