improve progress bar code