fix some bugs but the script is still not working