Fixed Error handling