error handling optimizations