Added better error handling for delete