Working of fixing a bug where the program seems to loop infinitely and calls displayProgress().