refactor cacheSolve