updated cachesolve to only solve once