cacheSolve coded + refactoring