modify script to fix bug