Adding error handling for the progress bar