better error handling for extraction