Updated the way that the script worked