Adjusted error handling