fixed the script, now working perfectly