fix script bugs