dynamically calculate progress bar