modify to improve the stability of gsdfmain.m