better handling for caching, so erros don't get cached