fixed the algorithm - now it will always work when the progress bar is flat

You can just do if(showError) {

}