refactor all scripts to handle asyn issue