clean codes

seperate the specification & implementation in mainForm;
rewrite functions for update_pd_tB()