added more error states to fail gracefully.