Implemented cacheSolve function