Updated to Error handling

updated to error handling