Upgraded the script