modify the script and it works better now