• I have updated the script with code from Farhan as well.