Calculate progress bar dynamically