wrote a cleaner version of cacheSolve