Error handling fix