adjusted to handle error_message object