added error handling and UI update on refresh