clean up the code and fixed a progress bar bug