fix script functionality