better error handling for remove resource