Error handling enhanced