Simplified the code to update the ProgressBar