added error handling for entity deletion