cleanup duplicated code.
Rewrite Progress Dialog