refactored progress bar code